﻿package com.wandian.controller
{
	import com.wandian.data.GameData;
	import com.wandian.model.AccountProxy;
	import com.wandian.model.RoomInfoProxy;
	import com.wandian.model.UserInfoProxy;
	import com.wandian.model.vo.PlayerVo;
	import com.wandian.model.vo.RoomVo;
	import com.wandian.view.mediator.FriendAndRoomPlayerMediator;
	import com.wandian.view.mediator.GameRoomMediator;
	import com.wandian.view.mediator.MaskGameMediator;
	import com.wandian.view.mediator.account.AccountMediator;
	import com.wandian.view.mediator.cornucopia.CornucopiaMediator;

	import flash.display.MovieClip;

	import org.puremvc.as3.interfaces.*;
	import org.puremvc.as3.patterns.command.*;

	public class CornucopiaCommand extends SimpleCommand
	{
		private var _global:GameData;
		private var _mcPanel:MovieClip;

		public function CornucopiaCommand()
		{
			this._global=GameData.getInstance();
			return;
		}

		override public function execute(notification:INotification):void
		{
			super.execute(notification);
			var userinfo:UserInfoProxy=facade.retrieveProxy(UserInfoProxy.NAME) as UserInfoProxy;
			switch (notification.getName())
			{
				case CLZNoticeName.SHOW_CORNUCOPIA_PANEL:
				{
					this.showCornucopia(notification);
					break;
				}
				case CLZNoticeName.CORNUCOPIA_TODAY_LIST_REQ:
				{
					userinfo.requestToDayCornucopiaList(notification.getBody() as int);
					break;
				}
				case CLZNoticeName.CORNUCOPIA_MY_LIST_REQ:
				{
					userinfo.requestMyCornucopiaList();
					break;
				}
				default:
				{
					break;
				}
			}
			return;
		}

		private function showCornucopia(param1:INotification):void
		{
			if (!this._mcPanel)
			{
				this._mcPanel=GameData.getMovieClip("CornucopiaPanel");
			}
			if (!Texas.I._mcWindosView.contains(this._mcPanel))
			{
				Texas.I._mcWindosView.addChildTo(this._mcPanel);
			}
			Texas.I._mcWindosView.centerXY(this._mcPanel);
			facade.registerMediator(new CornucopiaMediator(this._mcPanel));
			return;
		}

	}
}
